package com.itheima.proxydemo2;

public class UserServiceImpl implements UserService {
    @Override
    public void login(String loginName, String password) throws Exception {

//        long start = System.currentTimeMillis();

        if ("admin".equals(loginName) && "123456".equals(password)) {
            System.out.println("登录成功，欢迎光临本系统！");
        } else {
            throw new Exception("登录失败，用户名或密码错误！");
        }

        Thread.sleep(1000);
//        long end = System.currentTimeMillis();
//        System.out.println("login方法耗时：" + (end - start)/1000.0 + "s");

    }

    @Override
    public void deleteUsers() throws Exception {

//        long start = System.currentTimeMillis();

        System.out.println("成功删除了10个用户！");

        Thread.sleep(1500);
//        long end = System.currentTimeMillis();
//        System.out.println("deleteUsers方法耗时：" + (end - start)/1000.0 + "s");

    }

    @Override
    public String[] findUsers() throws Exception {

//        long start = System.currentTimeMillis();

        System.out.println("查询出了3个用户！");
        String[] names = {"张三", "李四", "王五"};
        Thread.sleep(500);

//        long end = System.currentTimeMillis();
//        System.out.println("findUsers方法耗时：" + (end - start)/1000.0 + "s");
        return names;
    }

    @Override
    public String[] findUsers1() throws Exception {
        System.out.println("查询出了3个用户！");
        String[] names = {"张三1", "李四1", "王五1"};
        Thread.sleep(700);
        return names;
    }
}
